package com.ys.迭代器;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * 描述: 迭代器测试:
 *
 *
 * @author CodeYang
 * @version 2020/12/25 14:27
 */
public class Test01 {

    public static void main(String[] args) {
        ArrayList<Object> arrayList = new ArrayList<>();
        arrayList.add(1);
        arrayList.add(2);
        arrayList.add("4");
        arrayList.add("ojk");

        //迭代器使用
        Iterator<Object> iterator = arrayList.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }

    }
}
